# -*-coding:utf-8 -*-

from flask import Flask, request, jsonify

app = Flask(__name__)
# 测试数据
user_info = {"user": "test01", "pwd": "111"}


# 登录
@app.route('/login', methods=['post'])
def login():
    data = request.form
    # 判断账号+密码
    if data.get('user') == None:
        return jsonify({'code': '0', 'msg': '账号不能为空'})
    elif data.get('pwd') == None:
        return ({'code': '0', 'msg': '密码不能为空'})
    elif user_info.get('user') == data.get('user') and user_info.get('pwd') == data.get('pwd'):
        return jsonify({'code': '1', 'msg': '登录成功'})
    else:
        return jsonify({'code': '0', 'msg': '账号或密码有误'})


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True, threaded=True)
